João Távora [Mon, 10 Oct 2022 12:57:26 +0000 (13:57 +0100)]
Do use eglot-connect-timeout if eglot-sync-connect is t
Reported by Eli Zaretskii <eliz@gnu.org>
* eglot.el (eglot--connect): Use eglot-connect-timeout in the case
eglot-sync-connect is t.
João Távora [Tue, 11 Oct 2022 11:02:46 +0000 (12:02 +0100)]
* eglot.el (version): actually bump to 1.9
João Távora [Sat, 8 Oct 2022 10:19:10 +0000 (11:19 +0100)]
Fix docstring of eglot-list-connections-mode
* eglot.el (eglot-list-connections-mode): Fix mistaken reference
to similar non-Eglot code.
João Távora [Wed, 5 Oct 2022 19:53:26 +0000 (20:53 +0100)]
Make eglot-code-actions usable non-interactively
* eglot.el (eglot--read-execute-code-action): New helper.
(eglot-code-actions): Use new helper. Offer non-interactive version.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/1070
João Távora [Tue, 4 Oct 2022 20:11:38 +0000 (21:11 +0100)]
Add half-baked m-x eglot-list-connections
Not very useful for now, but more functionality could be added later,
like bindings for disconnecting a given connection, switching to its
events buffers, or just listing some details like capabilities.
* eglot.el (eglot-list-connections-mode, eglot-list-connections):
New mode and function.
João Távora [Tue, 4 Oct 2022 18:32:02 +0000 (19:32 +0100)]
Rename "eglot -> eglot" in docstrings
* eglot.el (eglot-mode-line, eglot-client-capabilities)
(eglot--stay-out-of-p, eglot-managed-p)
(eglot-managed-mode-hook, eglot--managed-mode)
(eglot-current-server, eglot--current-server-or-lose)
(eglot--mode-line-format, eglot-xref-backend)
(eglot-imenu): Rename "EGLOT" -> "Eglot"
João Távora [Mon, 26 Sep 2022 12:35:34 +0000 (13:35 +0100)]
Make clojure-lsp handle more major modes at once
Suggested-by: Witoslaw Koczewski <wi@koczewski.de>
* eglot.el (eglot-server-programs): Enhance clojure-specific section.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/682
João Távora [Mon, 26 Sep 2022 10:43:39 +0000 (11:43 +0100)]
Add support for "single server, multiple modes"
Previously, if an entry such as:
((c++-mode c-mode) . ("clangd)")
were found in eglot-server-programs, it meant that opening a .cpp file
and a .c file in the same project and enabling eglot for both would
lead to two clangd instances. Now only one instance is created to
handle all buffers of those major modes, as long as they are in the
same project.
This change accomplishes this with minimal changes and NO modification
to the already complicated syntax of eglot-server-programs.
Naturally, this means that a subtle backward-incompatibility was
introduced. If, instead of "clangd", someone is using some kind
"c++-or-c-but-not-both-at-once" server, this commit now breaks that
person's configuration.
After analysing the entries of this variable, an educated guess was
made that this situation is rare. If it's not rare, then some change
to the syntax of eglot-server-programs will have to ensue.
* eglot.el (eglot-server-programs): Update docstring.
(eglot-lsp-server): Replace major-mode -> major-modes.
(eglot--lookup-mode): Rework.
(eglot--guess-contact): Rework.
(eglot--connect): Reword first parameter.
(eglot-reconnect): Use eglot--major-modes.
(eglot--read-server): Rework.
(eglot--ensure-list): New helper.
(eglot-current-server): Rework.
(eglot-handle-request workspace/configuration): Use first of
managed major modes.
* NEWS.md: Mention change.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/681
João Távora [Mon, 26 Sep 2022 09:23:53 +0000 (10:23 +0100)]
Shoosh byte-compilation warnings about line numbering functions
Also add warning at the top of file about not using functionality
incompatible with 26.3
* eglot.el:
(eglot-current-column, eglot-current-column): Use line-beginning-position
(eglot--xref-make-match): Use line-beginning-position,
line-end-position, line-number-at-pos
João Távora [Sat, 24 Sep 2022 08:54:04 +0000 (09:54 +0100)]
Fix blunder in eglot--guess-contact
* eglot.el (eglot--guess-contact): Add back
'split-string-and-unquote' lost in https://github.com/joaotavora/eglot/issues/940 fix.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/940
João Távora [Mon, 19 Sep 2022 15:19:33 +0000 (16:19 +0100)]
Revert "fix jdtls support"
This reverts commit
e5b021c01fceea02b7e6622cde0a347b842ca6f3.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/1008
João Távora [Mon, 19 Sep 2022 15:04:31 +0000 (16:04 +0100)]
Don't use three-argument plist-get
* eglot.el (eglot-handle-request): Don't use three-argument
plist-get.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/1024
João Távora [Sun, 18 Sep 2022 10:19:00 +0000 (11:19 +0100)]
Don't return hash tables from e-w-configuration-plist
* eglot.el (eglot-signal-didChangeConfiguration): Adjust.
(eglot-handle-request workspace-configuration): Adjust.
(eglot--workspace-configuration-plist): Don't return a hashtable.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/1033
João Távora [Sat, 17 Sep 2022 23:37:31 +0000 (00:37 +0100)]
Allow eglot-workspace-configuration to be a plist
Suggested-by: Augusto Stoffel <arstoffel@gmail.com>
* NEWS.md: Mention change.
* README.md (eglot-workspace-configuration): Update yet again. Update
examples to use pylsp.
* eglot.el (eglot--workspace-configuration-plist): Noop if already
a plist.
(eglot-handle-request workspace/configuration): Use
eglot--workspace-configuration-plist.
(eglot-workspace-configuration): Document variable.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/590
GitHub-reference: per https://github.com/joaotavora/eglot/issues/790
GitHub-reference: per https://github.com/joaotavora/eglot/issues/1033
João Távora [Sun, 18 Sep 2022 09:15:43 +0000 (10:15 +0100)]
Don't exceed max-specdl-size in big go projects
When invoking client/registerCapability for
workspace/didChangeWatchedFiles, Gopls lists each file to watch
separately. This makes eglot--glob-emit-{} emit a closure with an
'or' form containing a potentially large number of 're-search-forward'
forms.
For large Go project such as "Kubernetes", this list becomes so large
that -- for some reason I don't understand -- it triggers the
'max-specdl-size' limit.
An alternative using `regexp` opt doesn't seem to trigger the error.
* eglot.el (eglot--glob-emit-{}): Use regexp-opt.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/633
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/1067
João Távora [Sat, 17 Sep 2022 20:40:34 +0000 (21:40 +0100)]
Allow :initializationoptions in eglot-server-programs
Also see https://github.com/joaotavora/eglot/issues/1038.
This feature was poorly tested, and simply wouldn't work when trying
to initialize the server object.
The simple solution is to ignore :initializationOptions initarg in
this context. It is still stored separately as and accessed as the
'eglot--saved-initargs' slot.
Another complication arises in eglot--guess-contact, which tried too
hard to be able to compose an interactive prompt (when the server
program can't be found). The solution is just to give up when
:autoport or :initializationOptions is found. It's not easy or
practical to have the user provide non-string arguments via a string
interface like the minibuffer.
* eglot.el (initialize-instance :before eglot-lsp-server): Don't pass
:initializationOptions initarg onward.
(eglot--guess-contact): Simplify. Don't try heroics with
:autoport and :initializationOptions.
* eglot-tests.el (eglot-server-programs-simple-missing-executable):
Update test.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/940
João Távora [Sat, 17 Sep 2022 09:33:26 +0000 (10:33 +0100)]
Adjust last commit about workspace configuration
* README.md (way): Adjust.
* eglot.el (json): Don't require needlessly.
(eglot-show-workspace-configuration): Don't depend on json-mode.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/790
GitHub-reference: per https://github.com/joaotavora/eglot/issues/590
João Távora [Sat, 17 Sep 2022 00:28:52 +0000 (01:28 +0100)]
Rework readme.md about workspace configuration again
Also tweak eglot-show-workspace-configuration a bit.
* README.md (Workspace configuration): Rework.
* eglot.el (eglot-show-workspace-configuration): Rework.
(eglot--workspace-configuration-plist): New helper.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/590
Fredrik Bergroth [Mon, 10 Jan 2022 14:09:36 +0000 (15:09 +0100)]
Add eglot-show-configuration to debug workspace configurations
Also see https://github.com/joaotavora/eglot/issues/790, https://github.com/joaotavora/eglot/issues/1033.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/590
Theodor Thornhill [Fri, 9 Sep 2022 21:25:50 +0000 (23:25 +0200)]
Prefer documentchanges to changes in server-initiated edits
Some servers return both.
PR: https://github.com/joaotavora/eglot/issues/949
* eglot.el (eglot--apply-workspace-edit): When both documentChanges
and changes are present, prefer the documentChanges. By doing that we
ensure that we don't double edit, rendering the document in an
unusable state.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/704
jgart [Sat, 9 Jul 2022 00:16:29 +0000 (19:16 -0500)]
Add support for jedi-language-server (again)
* eglot.el (eglot-server-programs): Add jedi-language-server
* README.md: Mention jedi-language-server
* NEWS.md: Mention jedi-language-server
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/961
João Távora [Thu, 8 Sep 2022 10:53:11 +0000 (11:53 +0100)]
Don't return poorly supported "special elements" in eglot-imenu
Fix https://github.com/joaotavora/eglot/issues/758, https://github.com/joaotavora/eglot/issues/536, https://github.com/joaotavora/eglot/issues/535.
Eglot's eglot-imenu returned a structure compliant with the rules
outlined in imenu--index-alist. In particular, it returned some
elements of the form
(INDEX-NAME POSITION GOTO-FN ARGUMENTS...)
The original intention (mine) must have been to allow fancy
highlighting of the position navigated to with a custom GOTO-FN.
Not only was access to that fanciness never implemented, but many
other imenu frontends do not support such elements.
See for example https://github.com/joaotavora/eglot/issues/758, https://github.com/joaotavora/eglot/issues/536, https://github.com/joaotavora/eglot/issues/535. And also related issues in other
packages:
https://github.com/IvanMalison/flimenu/issues/6
https://github.com/bmag/imenu-list/issues/58
So it's best to remove this problematic feature for now. It can be
added back later.
* eglot.el (eglot-imenu): Simplify.
* NEWS.md: Mention change
Manuel Uberti [Thu, 8 Sep 2022 10:36:56 +0000 (10:36 +0000)]
Fix jdtls support
PR https://github.com/joaotavora/eglot/issues/1026
* eglot.el (eglot-server-programs): Add -data setup for java-mode.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/1008
Artem Pyanykh [Thu, 8 Sep 2022 10:36:07 +0000 (11:36 +0100)]
Add marksman server for markdown
* eglot.el (eglot-server-programs): Update.
* README (Connecting to a server): Add marksman.
* NEWS.md: Mention change.
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/1013
Christian Garbs [Tue, 26 Jul 2022 14:05:46 +0000 (16:05 +0200)]
Add out-of-box support for perl lsp server
* eglot.el (eglot-server-programs): Support Perl lsp.
* README.md: Update.
* NEWS.md: Update.
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: close https://github.com/joaotavora/eglot/issues/952
João Távora [Sun, 24 Jul 2022 18:45:30 +0000 (19:45 +0100)]
Merge commit '
7738854e09' to fix fallout of force-push in gnu elpa
João Távora [Fri, 22 Jul 2022 00:17:05 +0000 (01:17 +0100)]
Always default eglot-strict-mode to nil
it's mostly useful for developers/debugger. It's better to have the
latter remember to set it than users being hindered by it.
See https://github.com/joaotavora/eglot/issues/131#issuecomment-
1191997167
* eglot.el (eglot-strict-mode): default to nil.
João Távora [Tue, 19 Jul 2022 16:50:35 +0000 (17:50 +0100)]
Fix embarrassing paren-matching blunder in eglot.el
* eglot.el (eglot-handle-request workspace/applyEdit): Fix parens.
João Távora [Tue, 19 Jul 2022 12:57:52 +0000 (13:57 +0100)]
Reply more reasonably to server's workspace/applyedit
* eglot.el (eglot-handle-request): Return non-nil
(eglot--apply-workspace-edit): Signal jsonrpc-error, not error.
João Távora [Tue, 19 Jul 2022 12:55:59 +0000 (13:55 +0100)]
Appease byte-compiler warnings about wrong use of quotes
* eglot.el (eglot-stay-out-of, eglot--code-action): Just give it
what it wants.
João Távora [Mon, 18 Jul 2022 20:23:32 +0000 (21:23 +0100)]
Eglot-workspace-configuration can be a function
* README.md (Workspace configuration): Renamed from per-project
configuration. Rework.
* NEWS.md: Mention change.
* eglot.el (eglot-workspace-configuration): Overhaul.
(eglot-signal-didChangeConfiguration): Use new
eglot-workspace-configuration.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/967
João Távora [Fri, 15 Jul 2022 11:58:47 +0000 (12:58 +0100)]
Be more conservative with the lsp identifier guess
If the user is not requesting a prompt, opt for the safer approach
which is to get the location from textDocument/definition, not from
workspace/symbol. Because of things like function overloading, the
latter is not always successful in finding exactly the definition of
the thing one is invoking M-. on.
This requires using an xref-internal symbol, which is kind of
unfortunate.
* eglot.el (xref-backend-identifier-at-point): Rework.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/131
GitHub-reference: per https://github.com/joaotavora/eglot/issues/314
João Távora [Fri, 15 Jul 2022 11:01:44 +0000 (12:01 +0100)]
Guess the "lsp identifier at point"
* eglot.el (eglot--workspace-symbols): New helper.
(xref-backend-identifier-completion-table): Rework.
(xref-backend-identifier-at-point): Rework.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/131
GitHub-reference: per https://github.com/joaotavora/eglot/issues/314
João Távora [Fri, 15 Jul 2022 09:25:55 +0000 (10:25 +0100)]
Tweak some details, fix some bugs
eglot--recover-workspace-symbol-meta had a bug that still made it
choke on improper lists.
Also, when simply M-. to the thing at point, let's not lose time on
iterating a potentially out-of-date eglot--workspace-symbols-cache.
So clear it early in the pre-command-hook.
* eglot.el (eglot--workspace-symbols-cache): Move up.
(eglot--pre-command-hook): Clear eglot--workspace-symbols-cache here.
(eglot--recover-workspace-symbol-meta): Check for consp.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/131
João Távora [Thu, 14 Jul 2022 09:09:27 +0000 (10:09 +0100)]
Cosmetic decisions guaranteed to tick off someone somewhere (tm)
The symbols returned by the LSP server must be converted to unique
strings if Emacs is to present them in a list. On the other hand, the
search operates on the pattern and is completely controlled by the
backend. There is not much Eglot, the LSP client, can do about this.
Decided to present the unique string to the user, even though it could
be hidden. All the manner of :annotation-function,
:affixation-function, :group-funcion etc didn't seem to add much
value.
Grouping was especially useless, since it makes sense to respect the
LSP server's account of sorting score, so that better results bubble
up to the top.
* eglot.el (xref-backend-identifier-completion-table): Uniquify
symbols with containerName and kind.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/131
João Távora [Wed, 13 Jul 2022 15:42:10 +0000 (16:42 +0100)]
Experiment with grouping in xref-backend-identifier-completion-table
Doesn't look very good.
* eglot.el (xref-backend-identifier-completion-table): Add stuff.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/131
João Távora [Tue, 12 Jul 2022 23:44:32 +0000 (00:44 +0100)]
Make c-u m-. work half decently
* NEWS.md: Mention change.
* eglot.el (eglot--lsp-interface-alist): Add WorkspaceSymbol
(eglot--workspace-symbols-cache): New variable.
(eglot--recover-workspace-meta): New helper.
(xref-backend-identifier-completion-table): Complicate.
(xref-backend-definitions): Complicate.
(completion-category-overrides): Register a category and a style here.
(completion-styles-alist): Add eglot--lsp-backend-style style
(eglot--lsp-backend-style-call): New funtion.
(eglot--lsp-backend-style-all-completions): New function.
(eglot--lsp-backend-style-try-completion): New function.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/131
jgart [Sat, 9 Jul 2022 00:16:29 +0000 (19:16 -0500)]
Add support for jedi-language-server
* eglot.el (eglot-server-programs): Add jedi-language-server
* README.md: Mention jedi-language-server
* NEWS.md: Mention jedi-language-server
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/961
João Távora [Thu, 7 Jul 2022 11:30:03 +0000 (12:30 +0100)]
Prevent desktop.el from saving/restoring eglot--managed-mode
Although desktop.el compatibility is Emacs bughttps://github.com/joaotavora/eglot/issues/56407, the optimal
solution agreed to there is a bit more work than what I have time to
right now. See e.g.
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=bug%2356407https://github.com/joaotavora/eglot/issues/68. For
now, just use `with-eval-after-load'
* eglot.el (Hacks desktop): Add eglot--managed-mode to
desktop-minor-mode-handlers
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/990
João Távora [Fri, 24 Jun 2022 09:35:07 +0000 (10:35 +0100)]
Apply any additionaltextedits unconditionally
* eglot.el (eglot-completion-at-point): Apply any
additionalTextEdits unconditionally.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/981
jicksaw [Thu, 30 Jun 2022 07:39:33 +0000 (10:39 +0300)]
Reduce eldoc noise from hover messages
Also close https://github.com/joaotavora/eglot/issues/985
Only echo hover response content, without response range.
LSP specification says the range is meant to visualize a hover.
Maybe echoing the range is useful for some, but it seems
non-standard behavior.
Example issue: haskell-language-server responds with range set to
whole file when hovering a comment -> Large, useless eldoc
* eglot.el (eglot--hover-info): Remove text selected by range from
output
Copyright-paperwork-exempt: Yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/514
Basil L. Contovounesios [Fri, 24 Jun 2022 09:39:02 +0000 (12:39 +0300)]
Reduce memory footprint of eglot--{}
* eglot.el (eglot--{}): Specify smallest hash table :size, to spare
~1KiB according to memory-report-object-size.
See also https://github.com/joaotavora/eglot/pull/315.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/978
Yuan Fu [Sun, 12 Jun 2022 10:04:53 +0000 (03:04 -0700)]
Update docstring of eglot-events-buffer-size
* eglot.el (eglot-events-buffer-size): Mention that you need to
restart the connection for 'eglot-events-buffer-size' to take effect.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/974
GitHub-reference: close https://github.com/joaotavora/eglot/issues/776
João Távora [Thu, 19 May 2022 08:59:55 +0000 (09:59 +0100)]
Don't ignore flymake-no-changes-timeout
Also per https://github.com/joaotavora/eglot/issues/957.
Only actually and eagerly report LSP diagnotics if the user has
Flymake starting automatically on a timer (flymake-no-changes-timeout
is a number).
By contrast, if flymake-no-changes-timeout is nil, the user starts the
diagnostic collection process on-demand via 'M-x flymake-start'.
Since the control of such collection is impossible with LSP, we should
just hold on to whatever diagnostics we have (which are presumably
up-to-date) until the next invocation of 'eglot-flymake-backend'.
For now, this doesn't affect Flymake "list-only" diagnostics. Those
are reported via the 'flymake-list-only-diagonstics' variable and
are always communicated immediately to it.
* eglot.el: (eglot-handle-notification
textDocument/publishDiagnostics): Consult flymake-no-changes-timeout.
Suggested-by: Jim Davis <jim.jd.davis@gmail.com>
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/508
Theodor Thornhill [Mon, 9 May 2022 19:04:12 +0000 (21:04 +0200)]
Use format string instead of concat
* eglot.el (eglot-handle-notification): Because diagnostics code can
be integer or string, and integer fails the sequencep test, use format
to create this string.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/948
João Távora [Mon, 9 May 2022 00:17:58 +0000 (01:17 +0100)]
Fix egregious thinko in eglot--uri-to-path
One shouldn't unhex the URI before parsing it. Just consider a
filename with a # character in it. The character is encoded as C%23,
after unhexing the file name becomes.
/tmp/C#/Program.cs
Now, parsing this as the URL will fail completely as the # mean
"anchor" in URLs.
* eglot.el (eglot--uri-to-path): Fix thinko.
João Távora [Wed, 4 May 2022 20:47:21 +0000 (21:47 +0100)]
Consider diagnostic.code when generating flymake diagnostics
Not sure this will please everybody, can almost guess someone is going
to ask for a custom switch.
Instead this info (and the source) should be passed on to Flymake.
That's where the custom switch for controlling formatting of
diagnostic messages should exist. But that's too much work right now.
* eglot.el (eglot-handle-notification): Consider Diagnostic.code.
rbrtb [Tue, 3 May 2022 09:53:17 +0000 (09:53 +0000)]
Ensure exit-function of eglot-c-at-point runs on exact match
When the completion is exact match, exit-function should still run.
Say one is using auto-imports feature of pyright. One types foo, and
triggers the completion. There are two candidates: foo and foo_bar. If
one chooses foo, the status would be 'exact' instead of 'finished', thus
exit-function is not executed, foo is not auto-imported.
* eglot.el (eglot-completion-at-point): Consider 'exact status.
Copyright-paperwork-exempt: Yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/941
Tomasz Hołubowicz [Wed, 27 Apr 2022 11:48:47 +0000 (13:48 +0200)]
Add out-of-box support for purescript lsp server
* eglot.el (eglot-server-programs): Support purescript lsp.
* README.md: Update.
* NEWS.md: Update.
Copyright-paperwork-exempt: Yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/905
João Távora [Wed, 27 Apr 2022 10:11:52 +0000 (11:11 +0100)]
Ensure non-null :settings param in didchangeconfiguration notif
* eglot.el (eglot-signal-didChangeConfiguration): Use eglot--{}
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/936
Troels Henriksen [Fri, 15 Apr 2022 18:22:57 +0000 (20:22 +0200)]
Add out-of-box support for futhark lsp server
* eglot.el (eglot-server-programs): Support futhark lsp.
* README.md: Update.
* NEWS.md: Update.
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/922
João Távora [Wed, 6 Apr 2022 10:08:12 +0000 (11:08 +0100)]
Solve flymake diagnostics synchronization problems
A diagnostics-lazy server is one who doesn't re-report already
reported diagnostics when it received textDocument/didSave.
Such is the case of Clangd, for example. Before this change, saving
an Eglot/Clang-managed buffer with some diagnostics caused the Flymake
indicator to display Wait[0 0] until some change was actually done to
the buffer.
That is because Flymake, by default, wants diagnostics on buffer save,
per flymake-start-on-save-buffer. But it doesn't work to simply turn
that off. That's because if one types something and quickly saves,
and the LSP diagnostics do come in after the save (for some reason,
like server latency), then Flymake sometimes doesn't request any
diagnostics at all.
The reason for the Flymake behaviour wasn't investigated, but that
wasn't a very good solution either
Rather this change makes it so that when such a Flymake request comes
in, it always gets served immediately with the latest information.
The latest information is now always stored in eglot--diagnostics,
with eglot--unreported-diagnotics being removed. The up-to-date list
is reported to Flymake whenever it requests it. It is updated
whenever the LSP server decides to.
* eglot.el (eglot--last-reported-diagnostics): Delete.
(eglot--unreported-diagnostics): Delete.
(eglot--diagnostics): New variable..
(eglot--maybe-activate-editing-mode): Use eglot--diagnostics.
(eglot-handle-notification): Set eglot--diaggnostics.
(eglot-flymake-backend): Read eglot--diagnostics. Always report.
(eglot--report-to-flymake): Set eglot--diagnostics.
Billy.Zheng [Tue, 5 Apr 2022 11:45:47 +0000 (19:45 +0800)]
Update invocation for out-of-box dart ls support
* eglot.el (eglot-server-programs): Tweak dart-mode entry.
* README.md: Tweak Dart entry.
Co-authored-by: João Távora
Copyright-paperwork-exempt: Yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/862
João Távora [Mon, 4 Apr 2022 10:05:29 +0000 (11:05 +0100)]
Check textdocumentsync/willsave cap before sending it
* eglot.el (eglot--guess-contact): Default language-id to educated
guess when eglot--lookup-mode returns nil.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/823
João Távora [Mon, 4 Apr 2022 09:41:29 +0000 (10:41 +0100)]
Guess language-id if manually entering server program
* eglot.el (eglot--guess-contact): Default language-id to educated
guess when eglot--lookup-mode returns nil.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/837
João Távora [Mon, 4 Apr 2022 09:23:56 +0000 (10:23 +0100)]
Tweak eglot mode-line menus
* eglot.el (eglot-manual): Rename from eglot-read-documentation
(eglot-customize): Delete.
(eglot-menu): Rename from eglot-menu-map. Rework.
(eglot--mode-line-format): Tweak.
(eglot-menu-string): Rename from eglot-mode-line-string.
(Flymake customization): New source section.
* NEWS.md: Tweak.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/792
Felicián Németh [Sat, 15 Jan 2022 17:51:36 +0000 (18:51 +0100)]
Rework eglot's mode-line
Mimic flymake by replacing the old menus of the mode-line with
"context menus". List all usefull commands under the main menu
(eglot-menu-map), and commands related to LSP debugging under the
project menu (eglot-debug-map).
* eglot.el (eglot-read-documentation, eglot-customize): New
commands.
(eglot-mode-line-string): New defcustom.
(eglot-menu-map, eglot-debug-map,): New variables.
(eglot--mode-line-props): Rework to use eglot-menu-map and
eglot-debug-map.
(eglot--mode-line-format): Use eglot-mode-line-string.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/792
João Távora [Mon, 4 Apr 2022 08:39:59 +0000 (09:39 +0100)]
Make eglot--plist-keys a simple (non-map.el) helper again
This removes a nagging compilation warning when developing on Emacs
master.
There's not much point in depending on map.el just for this util. And
there' snot much point in making eglot--plist-keys go through a
generic dispatching mechanism when we happen to know the thing
being dispatched
* eglot.el (eglot--plist-keys): Define in helpers section.
João Távora [Thu, 31 Mar 2022 13:21:29 +0000 (14:21 +0100)]
Protect against empty firsttriggercharacter strings
Which some LS's like gopls like to send.
* eglot.el (eglot--post-self-insert-hook): Beware of empty strings.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/906
João Távora [Mon, 28 Mar 2022 10:00:44 +0000 (11:00 +0100)]
Easier initializationoptions in eglot-server-programs
Per https://github.com/joaotavora/eglot/issues/845.
* NEWS.md: Update.
* eglot.el (eglot-server-programs): Document new syntax.
(eglot-initialization-options): Can use initializationOptions from
server's saved initargs.
(eglot--connect): Allow a plist to be appended to a server
contact.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/901
João Távora [Mon, 28 Mar 2022 23:09:34 +0000 (00:09 +0100)]
Tweak on-type-formatting code
* eglot.el (eglot--post-self-insert-hook): Tweak.
(eglot-format): Tweak docstring.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/899
Felicián Németh [Wed, 23 Mar 2022 20:47:45 +0000 (21:47 +0100)]
Implement on-type-formatting support
* eglot.el (eglot-format): Add new optional argument `on-type-format'
to request :textDocument/onTypeFormatting, and ...
(eglot--post-self-insert-hook): ... call it from here when necessary.
* eglot-tests.el (eglot--simulate-key-event): New helper defun.
(rust-on-type-formatting): New test.
* NEWS.md: mention feature.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/899
Felicián Németh [Sun, 27 Mar 2022 20:58:44 +0000 (22:58 +0200)]
Map more emacs variables to lsp formattingoptions fields
* eglot.el (eglot-format): Map require-final-newline to
insertFinalNewline and delete-trailing-lines to trimFinalNewlines.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/900
Marcus Swanson [Sat, 26 Mar 2022 21:43:31 +0000 (22:43 +0100)]
Add omnisharp support for c#
* eglot.el (eglot-server-programs): Add omnisharp for C#.
* README.md: Document the above change.
Copyright-paperwork-exempt: Yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/897
João Távora [Thu, 24 Mar 2022 16:06:08 +0000 (16:06 +0000)]
Use bounds of thing at point when asking for code actions
* eglot.el (eglot--region-bounds): Consider bounds of things at
point.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/895
Felicián Németh [Sun, 20 Mar 2022 08:50:15 +0000 (09:50 +0100)]
Add simple support for workspacefolders
Close https://github.com/joaotavora/eglot/issues/893.
Clients can support workspaceFolders since LSP 3.6. rootUri and
rootPath are deprecated. Dynamic changes in folders are not
supported, i.e., this patch does not implement
workspace/didChangeWorkspaceFolders.
* eglot.el (eglot-client-capabilities): Add capability
`workspaceFolders'.
(eglot-workspace-folders): New cl-defgeneric.
(eglot--connect): Add workspaceFolders to initializeParams.
(eglot-handle-request workspace/workspaceFolders): New cl-defmethod.
João Távora [Fri, 18 Mar 2022 10:54:21 +0000 (10:54 +0000)]
Defend against broken move-to-column in recent emacs
* eglot.el (eglot-lsp-abiding-column): Use (min (point) (point-max))
This is a defensive fix for an Emacs/company-mode problem described
below.
The problem can be reproduced in Eglot before this commit with:
~/Source/Emacs/emacs/src/emacs -Q -f package-initialize -L \
~/Source/Emacs/company-mode -l company -f global-company-mode -l \
eglot.el ~/tmp/issue-860/args_out_of_range.c -f eglot -f \
display-line-numbers-mode -f toggle-debug-on-error
1 // args_out_of_range.c
2 struct Book {
3 int id;
4 char title[50]
5 } book = { 1024, "C" };
6
7 int main(int argc, char *argv[])
8 {
9
10 // Error when typing the dot to make "book."
11 book
12 return 0;
13 }
When one types the dot after the "book" on line 11, company-mode
displays a two-line overlay that visually encompasses line 12 after
"book", which has the "return 0;" statement. That line happens to
also hold a warning about incorrect syntax, one that starts at column
2.
Eglot uses 'move-to-column' to go that precise place.
In Emacs 27.2, move-to-column is unaffected by previous company-mode
overlays, even if the current line is being co-used visually by the
overlay. It moves to the right buffer position.
In Emacs master, this isn't true. It seems to be confounded by the
company-mode overlay and moves to eob, which eventually breaks Eglot
with a backtrace such as this one:
Debugger entered--Lisp error: (args-out-of-range #<buffer args_out_of_range.c> 110 124)
encode-coding-region(110 124 utf-16 t)
(length (encode-coding-region (or lbp (line-beginning-position)) (point) 'utf-16 t))
(- (length (encode-coding-region (or lbp (line-beginning-position)) (point) 'utf-16 t)) 2)
(/ (- (length (encode-coding-region (or lbp (line-beginning-position)) (point) 'utf-16 t)) 2) 2)
eglot-lsp-abiding-column(110)
(- column (eglot-lsp-abiding-column lbp))
(setq diff (- column (eglot-lsp-abiding-column lbp)))
(progn (setq diff (- column (eglot-lsp-abiding-column lbp))) (not (= 0 diff)))
(while (progn (setq diff (- column (eglot-lsp-abiding-column lbp))) (not (= 0 diff))) (condition-case eob-err (forward-char (/ (if (> diff 0) (1+ diff) (1- diff)) 2)) (end-of-buffer (throw '--cl-block-nil-- eob-err))) (setq --cl-var-- nil))
(let* ((lbp (line-beginning-position)) (diff nil) (--cl-var-- t)) (narrow-to-region lbp (line-end-position)) (move-to-column column) (while (progn (setq diff (- column (eglot-lsp-abiding-column lbp))) (not (= 0 diff))) (condition-case eob-err (forward-char (/ (if (> diff 0) (1+ diff) (1- diff)) 2)) (end-of-buffer (throw '--cl-block-nil-- eob-err))) (setq --cl-var-- nil)) nil)
(catch '--cl-block-nil-- (let* ((lbp (line-beginning-position)) (diff nil) (--cl-var-- t)) (narrow-to-region lbp (line-end-position)) (move-to-column column) (while (progn (setq diff (- column (eglot-lsp-abiding-column lbp))) (not (= 0 diff))) (condition-case eob-err (forward-char (/ (if (> diff 0) (1+ diff) (1- diff)) 2)) (end-of-buffer (throw '--cl-block-nil-- eob-err))) (setq --cl-var-- nil)) nil))
(save-restriction (catch '--cl-block-nil-- (let* ((lbp (line-beginning-position)) (diff nil) (--cl-var-- t)) (narrow-to-region lbp (line-end-position)) (move-to-column column) (while (progn (setq diff (- column (eglot-lsp-abiding-column lbp))) (not (= 0 diff))) (condition-case eob-err (forward-char (/ (if ... ... ...) 2)) (end-of-buffer (throw '--cl-block-nil-- eob-err))) (setq --cl-var-- nil)) nil)))
eglot-move-to-lsp-abiding-column(2)
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/860
João Távora [Tue, 15 Mar 2022 10:20:24 +0000 (10:20 +0000)]
Don't advertise didchangewatchedfiles on tramp
* eglot.el (eglot--trampish-p): New helper.
(eglot-client-capabilities): Use it.
(eglot--uri-to-path): Use it.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/883
Felicián Németh [Sat, 12 Mar 2022 09:57:53 +0000 (10:57 +0100)]
Change capability 'documentchanges' to t
Eglot does support woskspaceEdit/documentChanges, but failed to
advertise this fact.
Per https://github.com/joaotavora/eglot/issues/873.
* eglot.el (eglot-client-capabilities): Set documentChanges to t.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/853
Manuel Uberti [Fri, 11 Mar 2022 12:41:53 +0000 (13:41 +0100)]
Use new jdtls script for eclipse jdt
Per https://github.com/joaotavora/eglot/issues/864.
* eglot.el (eglot-server-programs): use new jdtls
(eglot--eclipse-jdt-contact, eglot--eclipse-jdt). Remove.
(eglot-execute-command eglot-eclipse-jdt): Remove.
(eglot-initialization-options eglot-eclipse-jdt): Remove.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/863
Augusto Stoffel [Thu, 10 Mar 2022 11:32:20 +0000 (12:32 +0100)]
Don't strip invisible text when formatting hover string
This was introduced in https://github.com/joaotavora/eglot/issues/482 due to a bad interaction with a specific
server. But this solution makes hyperlinks in Eldoc buffers
unclickable, because the markdown-mode function that visits a link
relies on the invisible text.
Per https://github.com/joaotavora/eglot/issues/866
* eglot.el (eglot--format-markup): Use buffer-string instead of
filter-buffer-substring
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/865
João Távora [Sun, 6 Mar 2022 11:15:18 +0000 (11:15 +0000)]
Have a couple of lsp faces inherit from basic "shadow"
* eglot.el (eglot-diagnostic-tag-unnecessary-face)
(eglot-diagnostic-tag-deprecated-face): Inherit from 'shadow'.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/858
Brian Leung [Tue, 1 Mar 2022 15:59:05 +0000 (07:59 -0800)]
Prevent empty diagnostic tags vector hiding main fontification
* eglot.el (eglot-handle-notification): Require that the resulting
list of faces is non-empty and that each face corresponds only to a
known tag.
For unknown tags, we don't pass any additional face information to
Flymake, and instead expect it to make the appropriate overlay with
the "severity" property of the Diagnostic.
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/851
Brian Leung [Sun, 23 Jan 2022 03:59:06 +0000 (19:59 -0800)]
Properly check the completionitem.deprecated property
* eglot.el (eglot-completion-at-point): Check the :deprecated property
is `t'. We do this so that a :deprecated property of :json-false does
not cause a completion candidate to be incorrectly marked as deprecated.
Stefan Kangas [Sat, 22 Jan 2022 03:40:12 +0000 (04:40 +0100)]
* eglot.el (eglot-handle-notification): silence byte-compiler.
Brian Leung [Thu, 13 Jan 2022 03:06:18 +0000 (19:06 -0800)]
Add support for optional completionitem.tags
* eglot.el (eglot--lsp-interface-alist): Add optional CompletionItem.tags.
(eglot-completion-at-point): Add :company-deprecated key and value,
checking for either the appropriate tag (1) in the :tags property, or
a truthy value for the :deprecated property.
(eglot-client-capabilities): Advertise tagSupport (for tag == 1) and
deprecatedSupport.
Also load an updated version of seq.el in Emacsen < 27.
* Makefile (ELPA_DEPS): Require latest seq.el.
Stefan Kangas [Sat, 22 Jan 2022 03:13:11 +0000 (04:13 +0100)]
Don't use :exclusive no
See https://github.com/joaotavora/eglot/issues/812 for background, in particular:
https://github.com/joaotavora/eglot/issues/812#issuecomment-
1014821345
* eglot.el (eglot-completion-at-point): Don't use :exclusive no, as it
leads to breakage in many cases.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/812
Theodor Thornhill [Thu, 20 Jan 2022 22:06:53 +0000 (23:06 +0100)]
Enable lsp project-wide diagnostics via flymake
* eglot.el (eglot-handle-notification): Pass on diagnostics from
unvisited files to flymake. Enables project-wide-diagnostics, so that
we can view all diagnostics in a given workspace. Uses new
functionality from flymake 1.2.1, hence the version bump.
* eglot-tests.el (project-wide-diagnostics-typescript): New tests
showcasing the possibility to see all related diagnostics in a
workspace.
* eglot-tests.el (project-wide-diagnostics-rust-analyzer): New tests
showcasing the possibility to see all related diagnostics in a
workspace.
* NEWS.md: Mention the new functionality
* README.md: Mention the new functionality
Derek Passen [Wed, 19 Jan 2022 01:56:13 +0000 (19:56 -0600)]
Add clojure-lsp support for clojure
* eglot.el (eglot-server-programs): Add clojure-lsp for Clojure.
* README.md: Document the above change.
Copyright-paperwork-exempt: Yes
Stefan Kangas [Mon, 17 Jan 2022 22:32:50 +0000 (23:32 +0100)]
; fix thinko in last commit
Stefan Kangas [Fri, 14 Jan 2022 12:03:44 +0000 (13:03 +0100)]
Change rust language server to rust-analyzer
rust-analyzer is the officially blessed Language Server for Rust:
https://github.com/rust-lang/rfcs/pull/2912
Also drop the special support code for RLS.
* eglot.el (eglot-server-programs): Add rust-mode language server
"rust-analyzer" and prefer it to the older "rls".
(eglot-rls, jsonrpc-connection-ready-p)
(eglot-handle-notification): Delete special support for "rls".
* eglot-tests.el (rls-analyzer-watches-files)
(rls-analyzer-hover-after-edit): Rename to ...
(rust-analyzer-watches-files)
(rust-analyzer-hover-after-edit): ... this. Update tests to work
with rust-analyzer.
* README.md: Update references for RLS to point to rust-analyzer.
* NEWS.md: Announce above change.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/803
Stefan Kangas [Sun, 16 Jan 2022 13:13:05 +0000 (14:13 +0100)]
; unbreak tests on emacs 26
* eglot.el (eglot--plist-keys): Define in Emacs 26, no longer
obsolete in Emacs 27 or later.
(eglot--check-object): Go back to eglot--plist-keys.
Stefan Kangas [Sun, 16 Jan 2022 12:05:16 +0000 (13:05 +0100)]
* eglot.el (eglot--server-capable): don't use obsolete name.
Stefan Kangas [Sun, 16 Jan 2022 12:05:13 +0000 (13:05 +0100)]
Obsolete eglot--plist-keys in favor of map-keys
* eglot.el (eglot--plist-keys): Make into obsolete function alias
for map-keys.
Stefan Kangas [Sun, 16 Jan 2022 12:04:27 +0000 (13:04 +0100)]
; * eglot.el: move obsolete definition to new section.
Stefan Kangas [Sat, 15 Jan 2022 23:12:05 +0000 (00:12 +0100)]
Remove unnecessary compatibility code
* eglot.el (eglot-mode-map): Remove unnecessary compatibility
code. We already depend on eldoc 0.11.0.
Stefan Kangas [Sat, 15 Jan 2022 16:37:42 +0000 (17:37 +0100)]
Improve backwards-compatibility of eglot-mode-map
* eglot.el (eglot-mode-map): Only bind to eldoc-doc-buffer in Emacs
28.1 or later.
Stefan Kangas [Sat, 15 Jan 2022 16:35:19 +0000 (17:35 +0100)]
* eglot.el (eglot-strict-mode): very minor docfix.
Stefan Kangas [Sat, 15 Jan 2022 12:47:30 +0000 (13:47 +0100)]
* eglot.el (eglot--connect): display seconds on timeout.
Stefan Kangas [Wed, 12 Jan 2022 23:50:35 +0000 (00:50 +0100)]
Print server command to events buffer
* eglot.el (eglot--connect): Print server command to events
buffer.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/476
Stefan Kangas [Thu, 13 Jan 2022 21:47:36 +0000 (22:47 +0100)]
; * eglot.el (eglot-server-initialized-hook): fix punctuation.
Theodor Thornhill [Mon, 30 Dec 2019 15:26:22 +0000 (16:26 +0100)]
Change from symbol-at-point to thing-at-point
* eglot.el (eglot-rename): Change from symbol-at-point to
thing-at-point to avoid interning a symbol. Add "unknown symbol" to
prompt when no symbol is found.
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: close https://github.com/joaotavora/eglot/issues/385
Brian Leung [Tue, 11 Jan 2022 05:48:21 +0000 (21:48 -0800)]
Support optional diagnostic.tags
https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#diagnosticTag
A DiagnosticTag can be either 1 (DiagnosticTag.Unnecessary) or
2 (DiagnosticTag.Deprecated). Following the rendering suggestions in
the protocol, we fade out Unnecessary code and strike-through
Deprecated code.
* eglot.el (eglot-diagnostic-tag-unnecessary-face)
(eglot-diagnostic-tag-deprecated-face): New faces.
(eglot--tag-faces): New defconst.
(eglot--lsp-interface-alist): Add Diagnostic.tags.
(eglot-client-capabilities): Advertise supported tags.
(eglot-handle-notification): Assign the appropriate properties.
* eglot-tests.el (diagnostic-tags-unnecessary-code): New test.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/794
Stefan Kangas [Thu, 13 Jan 2022 11:30:17 +0000 (12:30 +0100)]
* eglot.el: improve commentary section.
Stefan Kangas [Thu, 13 Jan 2022 10:52:29 +0000 (11:52 +0100)]
Support racket-langserver
* eglot.el (eglot-server-programs): Support racket-langserver.
* README.md:
* NEWS.md: Update for above changes.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/694
Stefan Kangas [Wed, 12 Jan 2022 18:35:22 +0000 (19:35 +0100)]
Bump eglot version to 1.8
* eglot.el (Version): Bump to 1.8.
* NEWS.md (1.8): Rename header from "(upcoming)".
Brian Leung [Tue, 11 Jan 2022 03:32:19 +0000 (19:32 -0800)]
Don't error out on unsupported diagnostic.codedescription
A codeDescription property is, at the time of writing, an object with
an href property (of type URI, or a string), denoting a "URI to open
with more information about the diagnostic error".
It's not obvious how best to put this into a Flymake diagostic
aside from simply appending it to the diagnostic message, so we'll
worry about it some other time.
* eglot.el (eglot--lsp-interface-alist)
(eglot-client-capabilities): Don't error out on unsupported
Diagnostic.codeDescription.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/768
Fredrik Bergroth [Wed, 15 Dec 2021 12:05:22 +0000 (13:05 +0100)]
Support autoimporttext from pyright language server
* eglot.el (eglot-completion-at-point): show autoImportText via company-docsig.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/769
Felicián Németh [Mon, 10 Jan 2022 19:21:21 +0000 (20:21 +0100)]
Add tooltip describing pending requests
* eglot.el (eglot--mode-line-format): Add tooltip to `pending'.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/784
Brian Leung [Sun, 9 Jan 2022 02:08:23 +0000 (18:08 -0800)]
Properly print error message of eglot-alternatives
* eglot.el (eglot-alternatives): Work with the listified form. This
allows presumed executables provided as (EXECUTABLE &rest ARGS...)
to be displayed in the error.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/786